package com.neusoft.work.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class MCPController {
    @Autowired
    private ChatClient chatClient;

    @PostMapping("/chat")
    public String chat(@RequestParam(value = "query", defaultValue = "请说一句鼓励上班人的心灵鸡汤，不要太长") String query, String style) {

        Prompt prompt = new Prompt(query);
        String str = chatClient.prompt(prompt)
                .system(s -> s.text("以{style}风格回答，并且说中文").param("style", style))
                .call()
                .content();

        System.out.println(str);
        return str;
    }

}
